<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('diyfield_update'); ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>修改拓展字段</title>
<link href="templates/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/jquery.nicescroll.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/laymain.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript">
   $(function () {
	   $("#infotype").change(function(){
		var v = $(this).val();
		$.ajax({
			url : "ajax_do.php?action=diyfield&type="+v,
			type:'get',
			dataType:'html',
			beforeSend:function(){},
			success:function(data, textStatus, xmlHttp){
				if(data != ''){
					$("#purviewList").html(data);
				}
			}
		});
	});
	 $("#fieldtype").change(function(){
		var v = $(this).val();
		$.ajax({
			url : "ajax_do.php?action=fieldtype&type="+v,
			type:'get',
			dataType:'html',
			beforeSend:function(){},
			success:function(data, textStatus, xmlHttp){
				if(data != ''){
					$("#expand").html(data);
				}
			}
		});
	});
        //初始化表单验证
        $("#form").initValidform();
    });

</script>
</head>

<body class="mainbody">
<?php
$row = $dosql->GetOne("SELECT * FROM `#@__diyfield` WHERE `id`=$id");
?>
<form name="form" id="form" method="post" action="diyfield_save.php" >
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回列表页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <a href="diyfield.php"><span>扩展字段管理</span></a>
  <i class="arrow"></i>
  <span>添加扩展字段</span>
  <a href="javascript:location.reload();" class="reload">刷新</a> 
</div>
<div class="line10"></div>
<!--/导航栏-->

<!--内容-->
<div id="floatHead" class="content-tab-wrap">
  <div class="content-tab">
    <div class="content-tab-ul-wrap">
      <ul>
        <li><a class="selected" href="javascript:;">修改扩展字段</a></li>
      </ul>
    </div>
  </div>
</div>

<div class="tab-content">
  <dl>
    <dt>所属模型</dt>
    <dd>
      <div class="rule-single-select">
        <select name="infotype" id="infotype" disabled="disabled" datatype="n1-16" sucmsg=" " errormsg="请选择模型！">
				<?php
				$model = array('0'=>'单页','1'=>'列表','4'=>'商品');
				foreach($model as $k=>$v)
				{	
					if($row['infotype'] == $k)
						$selected = 'selected="selected"';
					else
						$selected = '';

					echo "<option value=\"$k\" $selected>$v</option>";
				}
				
				//循环自定义模型
				$dosql->Execute("SELECT * FROM `#@__diymodel` ORDER BY `id` ASC");
				while($row2 = $dosql->GetArray())
				{
					if($row['infotype'] == $row2['id'])
						$selected = 'selected="selected"';
					else
						$selected = '';
					
					echo "<option value=\"".$row2['id']."\" $selected>".$row2['modeltitle']."</option>";
				}
				?>
		</select>
      </div>
    </dd>
		<input type="hidden" name="infotype" id="infotype" value="<?php echo $row['infotype']; ?>" />
  </dl>
  <dl>
    <dt>所属栏目</dt>
    <dd>
     	<div class="rule-multi-porp" id="purviewList">
          
		<?php
			echo '<span>';
			$catepriv = explode(',',$row['catepriv']);
			$dosql->Execute("SELECT * FROM `#@__infoclass` WHERE `infotype`='".$row['infotype']."' ORDER BY orderid ASC");
			while($row2 = $dosql->GetArray())
			{	
				if(in_array($row2['id'],$catepriv))
				$checked = 'checked="checked"';
				else
					$checked = '';
				echo '<input type="checkbox" name="classid[]" id="classid[]'.$row2['id'].'" value="'.$row2['id'].'" '.$checked.' /><label for="classid[]'.$row2['id'].'">'.$row2['classname'].'</label>';
			}
			echo  '</span>';
			?>
			</div>
    </dd>
  </dl>
		<dl>
			<dt>字段类型</dt>
			<dd>
			<div class="rule-single-select"> 
			<select name="fieldtype" id="fieldtype" datatype="*" errormsg="请选择字段类型！" sucmsg=" ">
			<?php if($row['fieldtype'] == 'varchar') echo '<option value="varchar">单行文本</option>'; ?>
			<?php if($row['fieldtype'] == 'text') echo '<option value="text">多行文本</option>'; ?>
			<?php if($row['fieldtype'] == 'mediumtext') echo '<option value="mediumtext">编辑器</option>'; ?>
			<?php if($row['fieldtype'] == 'datetime') echo '<option value="datetime">日期时间</option>'; ?>
			<?php if($row['fieldtype'] == 'int') echo '<option value="int">数字</option>'; ?>
			<?php if($row['fieldtype'] == 'decimal') echo '<option value="decimal">数字</option>'; ?>
			<?php if($row['fieldtype'] == 'checkbox') echo '<option value="checkbox">多选菜单</option>'; ?>
			<?php if($row['fieldtype'] == 'radio') echo '<option value="radio">单选菜单</option>'; ?>
			<?php if($row['fieldtype'] == 'select') echo '<option value="select">下拉菜单</option>'; ?>
			<?php if($row['fieldtype'] == 'file') echo '<option value="text">单个附件[上传]</option>'; ?>
			<?php if($row['fieldtype'] == 'fileall') echo '<option value="text">多个附件[上传]</option>'; ?>
			</select>
			</div>

			</dd>
		</dl>		
		  <dl>
			<dt>字段标示</dt>
			<dd>	<input type="hidden" name="fieldoldname" id="fieldoldname" value="<?php echo $row['fieldname']; ?>" />
			<input type="text" name="fieldname" id="fieldname" class="input" value="<?php echo $row['fieldname']; ?>" datatype="/^[^_][a-zA-Z\-\_]{0,48}[^_]$/" sucmsg="" errormsg="仅能字母开头，不能以下划线结尾 2-50位" ajaxurl="ajax_do.php?action=diyfieldname&old_name=<?php echo $row['fieldname']; ?>"  />
			  <span class="Validform_checktip">*字母、下划线，不可修改</span>
			</dd>
		  </dl> 
		  <dl>
			<dt>字段标题</dt>
			<dd>
				<input type="text" name="fieldtitle" id="fieldtitle" class="input" value="<?php echo $row['fieldtitle']; ?>" datatype="*" />
			  <span class="Validform_checktip">*例如：文章标题</span>
			</dd>
		  </dl>	
		<dl>
			<dt>字段提示</dt>
			<dd>
				<input type="text" name="fielddesc" id="fielddesc"  value="<?php echo htmlspecialchars($row['fielddesc']); ?>" class="input normal" />
			</dd>
		 </dl>	
		<?php
		  $type = $row['fieldtype'];
			if($row['fieldclass'] == 'normal') $normal = 'checked="checked"';else $normal='';
			if($row['fieldclass'] == 'short') $short = 'checked="checked"';else $short='';
			if($row['fieldclass'] == 'small') $small = 'checked="checked"';else $small='';
			if($row['fieldclass'] == 'mediumtext') $mediumtext = 'checked="checked"';else $mediumtext='';
			if($row['fieldclass'] == 'mediumtextmini') $mediumtextmini = 'checked="checked"';else $mediumtextmini='';
			if($row['fieldclass'] == 'image') $image = 'checked="checked"';else $image='';
			if($row['fieldclass'] == 'soft') $soft = 'checked="checked"';else $soft='';
			if($row['fieldclass'] == 'media') $media = 'checked="checked"';else $media='';
			if($row['fieldclass'] == 'all') $all = 'checked="checked"';else $all='';
		  switch($type)
			{	
				case 'varchar':
					echo' <dl>
							<dt>样式</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass"><input id="checkinfo_1" type="radio" name="fieldclass" value="normal" '.$normal.'/><label for="checkinfo_1">长(300px)</label>
								<input id="fieldclass_2" type="radio" name="fieldclass" value="short" '.$short.' /><label for="checkinfo_2">中(150px)</label>
								<input id="fieldclass_3" type="radio" name="fieldclass" value="small" '.$small.' /><label for="checkinfo_3">短(50px)</label>
								</span>
							  </div>
							</dd>
						  </dl>
						  <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong"  value="'.$row['fieldlong'].'" datatype="n1-3" class="input small" />
							<span class="Validform_checktip">*长度小于或等于255</span>
							</dd>
						 </dl>
						 <dl>
							<dt>默认值</dt>
							<dd>
								<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input normal" />
								<span class="Validform_checktip">*字段的默认字符，可为空</span>
							</dd>
						</dl>  
						<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>';
					break;
				case 'mediumtext':
					echo'
						<dl>
							<dt>编辑器类型</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass"><input id="fieldclass_1" type="radio" name="fieldclass" value="mediumtext" '.$mediumtext.' /><label for="checkinfo_1">标准型</label>
								<input id="fieldclass_2" type="radio" name="fieldclass" value="mediumtextmini" '.$mediumtextmini.'/><label for="checkinfo_2">简洁性</label>
								</span>
							  </div>
							</dd>
						  </dl>
						   <dl>
							<dt>默认值</dt>
							<dd>
								<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input normal" />
								<span class="Validform_checktip">*字段的默认字符，可为空</span>
							</dd>
						</dl>  
						<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>';
					break;
				case 'int':
					echo'
						<dl>
							<dt>字段类型</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass">
							<input id="fieldclass_1" type="radio" name="fieldclass" value="int" checked="checked" /><label for="checkinfo_1">整数[11]</label>
							
									<input id="fieldclass_2" type="radio" name="fieldclass" value="decimal"  disabled="disabled"/><label for="checkinfo_2">小数[10,2]</label>
								</span>
							  </div>
							  <span class="Validform_checktip">*[11] 和 [10,2] 为默认字段长度</span>
							</dd>
						  </dl>
						    <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong" datatype="*" value="'.$row['fieldlong'].'" class="input small" />
							<span class="Validform_checktip">*整数 如123456,长度默认为&quot;11&quot;| 小数如102.56 长度默认为&quot;10,2&quot;，&quot;10&quot;代表值总长度，&quot;2&quot;代表小数位数 </span>
							</dd>
						 </dl>
						  <dl>
							<dt>默认值</dt>
							<dd>
								<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input normal" />
								<span class="Validform_checktip">*字段的默认字符，可为空</span>
							</dd>
						</dl>  
						<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>';
					break;	
					case 'decimal':
					echo'
						<dl>
							<dt>字段类型</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass">
									<input id="fieldclass_1" type="radio" name="fieldclass" value="int" disabled="disabled"/><label for="checkinfo_1">整数[11]</label>
							
								<input id="fieldclass_2" type="radio" name="fieldclass" value="decimal" checked="checked" /><label for="checkinfo_2">小数[10,2]</label>

								</span>
							  </div>
							  <span class="Validform_checktip">*[11] 和 [10,2] 为默认字段长度</span>
							</dd>
						  </dl>
						    <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong" datatype="*" value="'.$row['fieldlong'].'" class="input small" />
							<span class="Validform_checktip">*整数 如123456,长度默认为&quot;11&quot;| 小数如102.56 长度默认为&quot;10,2&quot;，&quot;10&quot;代表值总长度，&quot;2&quot;代表小数位数 </span>
							</dd>
						 </dl>
						  <dl>
							<dt>默认值</dt>
							<dd>
								<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input normal" />
								<span class="Validform_checktip">*字段的默认字符，可为空</span>
							</dd>
						</dl>  
						<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>';
					break;	
					case 'checkbox':
					echo'
						   <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong" datatype="*" value="'.$row['fieldlong'].'" class="input small" />
							<span class="Validform_checktip">*认长度小于或等于 "255" </span>
							</dd>
						 </dl>
						  <dl>
							<dt>多选选项</dt>
							<dd>
								<textarea name="fieldsel" id="fieldsel" datatype="*" class="input" >'.$row['fieldsel'].'</textarea>
								<span class="Validform_checktip">*格式：&quot;选项=值&quot;，每个选项用&quot;,&quot;分割</span>
							</dd>
						</dl>  
						';
					break;
					case 'radio':
					echo'
						   <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong" datatype="*" value="'.$row['fieldlong'].'" class="input small" />
							<span class="Validform_checktip">*认长度小于或等于 "255" </span>
							</dd>
						 </dl>
						  <dl>
							<dt>单选选项</dt>
							<dd>
								<textarea name="fieldsel" id="fieldsel" datatype="*"  class="input" >'.$row['fieldsel'].'</textarea>
								<span class="Validform_checktip">*格式：&quot;选项=值&quot;，每个选项用&quot;,&quot;分割</span>
							</dd>
						</dl>  
						';
					break;	
					case 'select':
					echo'
						   <dl>
							<dt>字段长度</dt>
							<dd>
							<input type="text" name="fieldlong" id="fieldlong" value="'.$row['fieldlong'].'" datatype="*" class="input small" />
							<span class="Validform_checktip">*认长度小于或等于 "255" </span>
							</dd>
						 </dl>
						  <dl>
							<dt>下拉选项</dt>
							<dd>
								<textarea name="fieldsel" id="fieldsel" datatype="*" value="'.$row['fieldsel'].'" class="input" ></textarea>
								<span class="Validform_checktip">*格式：&quot;选项=值&quot;，每个选项用&quot;,&quot;分割</span>
							</dd>
						</dl>  
						';
					break;	
					case 'file':
					echo'
						 <dl>
							<dt>上传类型</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass"><input id="fieldclass_1" type="radio" name="fieldclass" value="all" '.$all.' /><label for="checkinfo_1">全部</label>
								<input id="fieldclass_2" type="radio" name="fieldclass" value="image" '.$image.' /><label for="checkinfo_2">图片</label>
								<input id="fieldclass_3" type="radio" name="fieldclass" value="soft" '.$soft.'/><label for="checkinfo_3">软件</label>
								<input id="fieldclass_4" type="radio" name="fieldclass" value="media" '.$media.'/><label for="checkinfo_4">媒体</label>
								</span>
							  </div>
							  <span class="Validform_checktip"></span>
							</dd>
						  </dl><script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
						';
					break;
					case 'fileall':
					echo'
						 <dl>
							<dt>上传类型</dt>
							<dd>
							  <div class="rule-multi-radio">
								<span id="fieldclass"><input id="fieldclass_1" type="radio" name="fieldclass" value="all" '.$all.' /><label for="checkinfo_1">全部</label>
								<input id="fieldclass_2" type="radio" name="fieldclass" value="image" '.$image.' /><label for="checkinfo_2">图片</label>
								<input id="fieldclass_3" type="radio" name="fieldclass" value="soft" '.$soft.'/><label for="checkinfo_3">软件</label>
								<input id="fieldclass_4" type="radio" name="fieldclass" value="media" '.$media.'/><label for="checkinfo_4">媒体</label>
								</span>
							  </div>
							  <span class="Validform_checktip"></span>
							</dd>
							<dl>
							<dt>上传数量</dt>
							<dd>
							<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input small" />
							<span class="Validform_checktip">*默认单次上传最多50个文件 </span>
							</dd>
						 </dl>
						  </dl><script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
						';
					break;
				default:
				echo '  <dl>
							<dt>默认值</dt>
							<dd>
								<input type="text" name="fieldsel" id="fieldsel" value="'.$row['fieldsel'].'" class="input normal" />
								<span class="Validform_checktip">*字段的默认字符，可为空</span>
							</dd>
						</dl>  ';
			}
		  
		?>		  
		  <dl>
			<dt>校验正则</dt>
			<dd>
				<input type="text" name="fieldcheck" id="fieldcheck" value="<?php echo $row['fieldcheck']; ?>" class="input normal" />
			  <span class="Validform_checktip">*不需校验数据请留空</span>
			</dd>
		  </dl> 
		  <dl>
			<dt>未通过提示</dt>
			<dd>
			<textarea name="fieldcback" rows="2" cols="20" id="fieldcback" class="input"><?php echo $row['fieldcback']; ?></textarea>

			  <span class="Validform_checktip">*字段的默认字符，可为空</span>
			</dd>
		  </dl> 
		   <dl>
    <dt>排列排序</dt>
    <dd>
     <input type="text" name="orderid" id="orderid" class="input small" value="<?php echo $row['orderid']; ?>" />
    </dd>
  </dl>
		   <dl>
    <dt>审　核</dt>
    <dd>
      <div class="rule-multi-radio">
        <span id="checkinfo"><input id="checkinfo_1" type="radio" name="checkinfo" value="true" <?php if($row['checkinfo'] == 'true') echo 'checked="checked"'; ?> /><label for="checkinfo_1">启用</label>
		<input id="checkinfo_2" type="radio" name="checkinfo" value="false" <?php if($row['checkinfo'] == 'false') echo 'checked="checked"'; ?> /><label for="checkinfo_2">禁用</label>
		</span>
      </div>
    </dd>
  </dl>
	
</div>
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap">
  <input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn" />
    <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
		<input type="hidden" name="action" id="action" value="update" />
		<input type="hidden" name="id" id="id" value="<?php echo $id; ?>" />
		<input type="hidden" name="fieldname_b" id="fieldname_b" value="<?php echo $row['fieldname']; ?>" />
  </div>
</div>
<!--/工具栏-->

</form>
</body>
</html>